#ifndef PLAYER_H
#define PLAYER_H

#include "person.h"
#include <vector>
#include "../states/context.h"

/**
 * \brief Player creator
 *
 * This class provides a player
 */

class Player:public Person
{
protected:

    stringstream ss; /** This stringstream will containt the messages btw player and server. */

    unsigned short id; /** Player number identificator */

    int timelast; /** How long is from the last sended message */
    int moment; /** Turn moment. */
    int velocity; /** Player velocity (for run, dash). */
    //timelast is used to create a buffer of data to send to the server

    bool sentcommand; 
  
    Context cont; /** This instance of Contex will select the state depending on the inputs. */

public:

    Parser parser; /** Composition of Parser class. */ //Public?

    /**
     * \brief Default constructor with inicialization.
     */
    Player(string TeamName);

    //Player create(); //(init Team) or (reconnect Team Unum)

    /**
     * \brief Destructor [~Player].
     */
    void destroy(); //(bye)

    /**
     * \brief With this function the player will folloe the ball.
     * \param kickangle Kick the ball with this angle.
     * \param kickforce Kick the ball with this force.
     */
    void follow_ball(int kickangle, int kickforce) ;

    /**
     * \brief This function is to kick the ball to the goal.
     */
    void kicktogoal();

    /**
     * \brief Run ahead with a determined power.
     * \param power Represents the energy you want to perform this task.
     */
    void run(double power); //(dash power)

    //void pass(); PASAR

    /**
     * \brief Kick the ball with a given power and direction.
     * \param power Represents the energy you want to perform this task.
     * \param direction Kick the ball with this angle or direction.
     */
    void kick(int power,int direction);//(kick Power Direction)

    /**
     * \brief Only the goolkeaper can use this function to stop the ball with the hands .
     */
    void ballHandling();

    /**
     * \brief Turn the player body with this moment.
     * \param moment Turning moment applied over the player.
     */
    void turn(int moment); //(turn Moment)

    /**
     * \brief Turn the player neck with this moment.
     * \param angle Angle that player turns his head
     */
    void turn_neck(int angle);//(turn_neck Angle)

    //void dribble();//¿REGATEAR?

    /**
     * \brief This function is used to initialize the position of the player.
     * \param x X initial position
     * \param y Y initial position
     */
    void move(int x, int y); // (move x y)


    void catch_dir(int dir); //(catch Direction)

    /**
     * \brief Read the player status and position from the server
     */
    void get_status(); //(sense_body)


    /**
     * \brief Choose the state accordingly to the parser inputs
     */
    void handle_state();


    void see();
    void listen();
    void yell(string message);//(say Message)

    void send_command(); 


};

#endif // PLAYER_H
